package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.InventoryDao;
import cn.gson.springboot.model.mapper.InventoryMapper;
import cn.gson.springboot.model.pojos.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class InventoryService {
    @Autowired
    InventoryMapper invMapper;
    @Autowired
    InventoryDao invDao;
    public List<Inventory> selectInventory(Integer warId,String content){
        return invMapper.selectInventory(warId,content);
    }
    public List<Map<String,Object>> computeInventoryCount(){
        return invMapper.computeInventoryCount();
    }

    public List<Map<String,Object>> computeInventorySort(){
        return invMapper.computeInventorySort();
    }

    public List<Map<String,Object>> computeInventoryFlowCount(){
        return invMapper.computeInventoryFlowCount();
    }

    public List<Map<String,Object>> computeInventoryFlowOperation(){
        return invMapper.computeInventoryFlowOperation();
    }

    public List<Map<String,Object>> computeInventoryFlowIntoMonth(){
        return invMapper.computeInventoryFlowIntoMonth();
    }

    @Transactional(transactionManager = "transactionManager")
    public void saveInventory(Inventory inventory){
        invDao.save(inventory);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deleteInventory(Integer invId){
        invDao.deleteById(invId);
    }
}
